
package ch.hearc.meteo.imp.afficheur.real;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.nilo.plaf.nimrod.NimRODLookAndFeel;
import com.nilo.plaf.nimrod.NimRODTheme;

import ch.hearc.meteo.imp.afficheur.real.moo.StationMeteoElement;
import ch.hearc.meteo.imp.afficheur.real.vue.JPanelCentral;
import ch.hearc.meteo.imp.afficheur.real.vue.JPanelInformationsMeteo;
import ch.hearc.meteo.imp.afficheur.real.vue.JPanelLeft;
import ch.hearc.meteo.spec.reseau.MeteoServiceWrapper_I;

public abstract class JFrameStationMeteo extends JFrame
	{

	/*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/

	protected JFrameStationMeteo()
		{
		applyLookAndFeel();
		this.setMinimumSize(new Dimension(800, 600));
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	public static JFrameStationMeteo getInstance()
		{
		return instance;
		}

	public void refreshSelectedStations(StationMeteoElement stationMeteoElement)
		{

		}

	public JPanelCentral getPanelCentral()
		{
		return null;
		}

	public JPanelLeft getPanelLeft()
		{
		return panelLeft;
		}

	public JPanelInformationsMeteo getPanelInformationsMeteo()
		{
		return null;
		}

	public void addMeteoServiceWrapper(MeteoServiceWrapper_I meteoServiceWrapper_I, AfficheurService afficheurService)
		{
		}

	public void removeMeteoServiceWrapper(MeteoServiceWrapper_I meteoServiceWrapper_I, AfficheurService afficheurService)
		{

		}

	/*------------------------------*\
	|*				Set				*|
	\*------------------------------*/

	/*------------------------------*\
	|*				Get				*|
	\*------------------------------*/

	public boolean isLocal()
		{
		return this.isLocal;
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	private void applyLookAndFeel()
		{
		try
			{
			NimRODTheme nt = new NimRODTheme();

			nt.setPrimary1(COLOR_P1);
			nt.setPrimary2(COLOR_P2);
			nt.setPrimary3(COLOR_P3);
			nt.setSecondary1(COLOR_S1);
			nt.setSecondary2(COLOR_S2);
			nt.setSecondary3(COLOR_S3);
			nt.setWhite(COLOR_WHITE);
			nt.setBlack(COLOR_BLACK);
			nt.setMenuOpacity(MENU_OPACITY);
			nt.setFrameOpacity(FRAME_OPACITY);

			//Application du LookAndFeel
			NimRODLookAndFeel NimRODLF = new NimRODLookAndFeel();
			NimRODLookAndFeel.setCurrentTheme(nt);
			UIManager.setLookAndFeel(NimRODLF);
			}
		catch (UnsupportedLookAndFeelException ex)
			{

			}
		}

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/

	//Tools
	protected static JFrameStationMeteo instance = null;
	protected boolean isLocal;
	protected JPanelLeft panelLeft;
	//GREEN / Black
	public static final Color COLOR_P1 = hex2Rgb("#52B800");
	public static final Color COLOR_P2 = hex2Rgb("#5CC200");
	public static final Color COLOR_P3 = hex2Rgb("#66CC00");
	public static final Color COLOR_S1 = hex2Rgb("#1F1F1F");
	public static final Color COLOR_S2 = hex2Rgb("#292929");
	public static final Color COLOR_S3 = hex2Rgb("#333333");
	public static final Color COLOR_WHITE = hex2Rgb("#000000");
	public static final Color COLOR_BLACK = hex2Rgb("#FFFFFF");
	public static final int MENU_OPACITY = 195;
	public static final int FRAME_OPACITY = 180;

	public static Color hex2Rgb(String colorStr)
		{
		return new Color(Integer.valueOf(colorStr.substring(1, 3), 16), Integer.valueOf(colorStr.substring(3, 5), 16), Integer.valueOf(colorStr.substring(5, 7), 16));
		}

	}
